package com.example.androidbookmarks;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.net.Socket;

import android.util.Log;

public class SendDataServer {
	private final String IP = "192.168.1.101";
	private final int POST = 4322;
	String dataOut = "Data from device android";
	
	public SendDataServer(){
		
	}
	
	public void run(String data){
		try {
			Socket s = new Socket(IP, POST);
			
			PrintWriter out = new PrintWriter(s.getOutputStream(), true);
			Reader reader = new InputStreamReader(s.getInputStream());
			BufferedReader in = new BufferedReader(reader);
			// Send
			out.println(data);
			while (!in.ready()) {
				
			}		
			// Received
			Log.v("", "in.readLine(): " + in.readLine());
			out.close();
			in.close();
			s.close();
		} catch (Exception e) {
			System.out.print("Error!\n");
		}
	}
}
